//
//  OrderListHeaderTableViewHeaderFooterView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/26.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "OrderListHeaderTableViewHeaderFooterView.h"

@implementation OrderListHeaderTableViewHeaderFooterView
{
    GLGWLabel * leftTypeLabel;
    GLGWLabel * rightTypeLabel;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        GLGWView * garyView = [[GLGWView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(10)) inSuperView:self];
        garyView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        //
        GLGWView * titleTypeView = [[GLGWView alloc] initWithFrame:CGRectMake(0, kHeightProportion_In_iPhoneTriploid(10), KScreenWidth,kHeightProportion_In_iPhoneTriploid(40) ) inSuperView:self];
        titleTypeView.backgroundColor = [UIColor whiteColor];
        //
        GLGWLabel * titleLabel = [[GLGWLabel alloc] initWithFont:BOLDSYSTEMFONT(16) theColor:kColor_Rule_Yellow inSuperView:titleTypeView];
        NSString *str = @" 极速交易商品";
        titleLabel.attributedText = [GLGWLabel addImageName:@"icon_changqiqiugou" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(19), kHeightProportion_In_iPhoneTriploid(21)) theTextString:str atImageIndex:0];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(titleTypeView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(titleTypeView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(9));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        leftTypeLabel = titleLabel;
        //
        rightTypeLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Yellow inSuperView:titleTypeView];
        rightTypeLabel.text = @"卖家确认中";
        [rightTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(titleTypeView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(titleTypeView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        
        //
        GLGWView * lineView = [[GLGWView alloc] initWithInSuperView:titleTypeView];
        lineView.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.left.bottom.equalTo(titleTypeView).offset(0);
            make.height.equalTo(@1);
        }];
    }
    return self;
}

- (void)setDetailListModel:(AllOrderDetailListModel *)detailListModel
{
    _detailListModel = detailListModel;
    if (detailListModel.tradingMode == 1) { // 常规
        NSString *str = @" 普通商品";
        leftTypeLabel.attributedText = [GLGWLabel addImageName:@"icon_changqiqiugou" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(19), kHeightProportion_In_iPhoneTriploid(21)) theTextString:str atImageIndex:0];
    } else {
        NSString *str = @" 极速交易商品";  // 这里文字和图片 都跟切图上不一致
        leftTypeLabel.attributedText = [GLGWLabel addImageName:@"icon_jisujiaoyi" theImageFram:CGRectMake(0, -5, kWidthProportion_In_iPhoneTriploid(20), kHeightProportion_In_iPhoneTriploid(20)) theTextString:str atImageIndex:0];
    }
    NSString *titlStr;
    if (self.accountType == AccountType_FreeManagers) {
        // 1：确认中(卖家：待您确认，买家/自由经理人：卖家确认中)2：待支付；3：线下支付待确认；4：待商家发货；5：待收货；6：交易完成；18：支付超时；19：订单取消 '
        titlStr = @"卖家确认中";
    } else {
        titlStr = @"待您确认";
    }
    
    rightTypeLabel.textColor = [UIColor colorWithHexString:@"#A89A60"];
    switch (detailListModel.orderStatus) {
        case 1:
            rightTypeLabel.text = titlStr;
            break;
        case 2:
            rightTypeLabel.text = @"等待支付";
            break;
        case 3:
            rightTypeLabel.text = @"线下支付待确认";
            break;
        case 4:
            rightTypeLabel.text = @"待商家发货";
            break;
        case 5:
            rightTypeLabel.text = @"等待收货";
            break;
        case 6:
            rightTypeLabel.text = @"交易完成";
            rightTypeLabel.textColor = [UIColor colorWithHexString:@"#353535"];
            break;
        case 18:
            rightTypeLabel.text = @"支付超时";
            break;
        case 19:
            rightTypeLabel.text = @"已取消";
            rightTypeLabel.textColor = [UIColor colorWithHexString:@"#999999"];
            break;
        default:
            break;
    }
}

@end
